package com.lzy.cloud.goods.service.GoodsServiceImpl;

import com.lzy.cloud.goods.dtos.CarConfigDto;
import com.lzy.cloud.goods.entity.CarConfig;
import com.lzy.cloud.goods.mapper.CarConfigMapperExt;
import com.lzy.cloud.goods.service.CarConfigService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2018/6/9.
 */
@Service
public class CarConfigServiceImpl implements CarConfigService{

    @Autowired
    CarConfigMapperExt carConfigMapperExt;

    @Override
    public Boolean add(CarConfigDto carConfigDto) {
        return carConfigMapperExt.insertSelective(DozerUtils.map(carConfigDto, CarConfig.class))>0;
    }

    @Override
    public Boolean delById(Long id) {
        return carConfigMapperExt.deleteByPrimaryKey(id)>0;
    }

    @Override
    public Boolean delByKey(CarConfigDto dto) {
        return carConfigMapperExt.delByKey(dto)>0;
    }

    @Override
    public Boolean update(CarConfigDto carConfigDto) {
        return carConfigMapperExt.updateByPrimaryKeySelective(DozerUtils.map(carConfigDto,CarConfig.class))>0;
    }

    @Override
    public List<CarConfigDto> selectList(CarConfigDto carConfigDto) {
        return carConfigMapperExt.selectList(carConfigDto);
    }

    @Override
    public CarConfigDto selectaById(Long id) {
        return DozerUtils.map(carConfigMapperExt.selectByPrimaryKey(id),CarConfigDto.class);
    }

    @Override
    public Boolean delByKeyTrue(CarConfigDto carConfigDto) {
        return carConfigMapperExt.delByKeyTrue(carConfigDto)>0;
    }
}
